import loadable from '@loadable/component'
import { RouteObject, Navigate } from 'react-router-dom'

const Auth = loadable(() => import('./Auth'))
const Home = loadable(() => import('@/pages/home'))
const Cate = loadable(() => import('@/pages/cate'))
const Find = loadable(() => import('@/pages/find'))
const My = loadable(() => import('@/pages/my'))
const Login = loadable(() => import('@/pages/my/login'))
const Register = loadable(() => import('@/pages/my/register'))
const Updateuserinfo = loadable(() => import('@/pages/my/updateuserinfo'))
const ResetPassword = loadable(() => import('@/pages/my/resetpassword'))
const Order = loadable(() => import('@/pages/my/order'))
const Layout = loadable(() => import('@/pages/layout'))
const GoodsDetail = loadable(() => import('@/pages/goodsDetail'))
const Catepage = loadable(() => import('@/pages/cate/Pagelist'))
const ArticleInfo = loadable(() => import('@/pages/find/ArticleInfo'))
const Car = loadable(() => import('@/pages/my/car'))
const Adress = loadable(() => import('@/pages/my/adress/adresslist'))
const AdresEdit = loadable(() => import('@/pages/my/adress/addrEdit/index'))
const ConfirmOrder = loadable(() => import('@/pages/my/order/confirmOrder'))
const Payment = loadable(() => import('@/pages/my/order/payment'))
const Payment1 = loadable(() => import('@/pages/my/order/payment1'))
const Payment2 = loadable(() => import('@/pages/my/order/payment2'))
const Agreement = loadable(() => import('@/pages/my/order/agreement'))
const PayResult = loadable(() => import('@/pages/my/order/payResult'))
const OrderBack = loadable(() => import('@/pages/my/order/orderBack'))
const PayResult1 = loadable(() => import('@/pages/my/order/payResult1'))
const PayResult2 = loadable(() => import('@/pages/my/order/payResult2'))
// const OrderBack = loadable(() => import('@/pages/my/order/orderBack'))
const Goodscolect = loadable(() => import('@/pages/my/colect/goodscolect'))
const Artilcolect = loadable(() => import('@/pages/my/colect/artilcolect'))
const router: RouteObject[] = [
    {
        path: '/',
        element: <Layout></Layout>,
        children: [
            {
                index: true,
                element: <Home></Home>
            },
            {
                path: '/home',
                element: <Home></Home>
            },
            {
                path: '/cate',
                element: <Layout></Layout>,
                children: [
                    {
                        index: true,
                        element: <Cate></Cate>,
                    },
                    {
                        path: 'catelist',
                        element: <Catepage></Catepage>,
                    },
                    {
                        path: 'goodsdetail',
                        element: <GoodsDetail></GoodsDetail>
                    },
                ]
            },
            {
                path: '/find',
                element: <Layout></Layout>,
                children: [
                    {
                        index: true,
                        element: <Find></Find>
                    },
                    {
                        path: 'articleInfo',
                        element: <ArticleInfo></ArticleInfo>
                    }


                ]
            },
            {
                path: '/my',
                element: <Layout></Layout>,
                children: [
                    {
                        index: true,
                        element: <My></My>,
                    },
                    {
                        path: 'login',
                        element: <Login></Login>
                    },
                    {
                        path: 'updateuserinfo',
                        element: <Auth><Updateuserinfo></Updateuserinfo></Auth>
                    },
                    {
                        path: 'register',
                        element: <Register></Register>
                    },
                    {
                        path: 'resetpassword',
                        element: <ResetPassword></ResetPassword>
                    },
                    {
                        path: 'order',
                        element: <Layout></Layout>,
                        children: [
                            {
                                index: true,
                                element: <Auth><Order></Order></Auth>
                            },
                            {
                                path: 'confirmorder',
                                element: <Auth><ConfirmOrder></ConfirmOrder></Auth>
                            },
                            {
                                path: 'payment',
                                element: <Auth><Payment></Payment></Auth>
                            },
                            {
                                path: 'payment1',
                                element: <Auth><Payment1></Payment1></Auth>
                            },
                            {
                                path: 'payment2',
                                element: <Auth><Payment2></Payment2></Auth>
                            },
                            {
                                path: 'agreement',
                                element: <Auth><Agreement></Agreement></Auth>
                            },
                            {
                                path: 'payresult',
                                element: <Auth><PayResult></PayResult></Auth>
                            },
                            {
                                path: 'payresult1',
                                element: <Auth><PayResult1></PayResult1></Auth>
                            },
                            {
                                path: 'orderBack',
                                element: <Auth><OrderBack></OrderBack></Auth>
                            },
                            {
                                path: 'payresult2',
                                element: <Auth><PayResult2></PayResult2></Auth>
                            },

                            // {
                            //     path: 'orderBack',
                            //     element: <Auth><OrderBack></OrderBack></Auth>
                            // }
                        ]
                    },
                    {

                        path: 'car',
                        element: <Car></Car>
                    },
                    {
                        path: 'adresspage',
                        element: <Layout></Layout>,
                        children: [
                            {
                                index: true,
                                element: <Auth><Adress></Adress></Auth>
                            },
                            {
                                path: 'adresedits',
                                element: <Auth><AdresEdit></AdresEdit></Auth>
                            },

                        ]
                    },
                    {
                        path: 'artilcolect',
                        element: < Artilcolect></ Artilcolect >
                    },
                    {
                        path: 'goodscolect',
                        element: <Goodscolect ></Goodscolect>
                    },
                ]
            },
        ]
    },
    {
        path: '*',
        element: <Navigate to="/"></Navigate>
    },
]

export default router